<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.fg.model.ProductVO, java.util.Map" %>

<%
Map resultMap = (Map)request.getAttribute("resultMap");
ProductVO product = (ProductVO)resultMap.get("product");
String imagePath = "https://freegive-uploaded-files.s3.amazonaws.com/images/";
boolean me = (Boolean)resultMap.get("me");
%>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Index Page</title>

<link rel="stylesheet" type="text/css" media="all" href="/css/common.css">
<link rel="stylesheet" type="text/css" media="all" href="/css/postProduct.css">


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery.form.js"></script>
<script type="text/javascript" src="/js/common.js"></script>
<script type="text/javascript" src="/js/loadProduct.js"></script>



</head>


<body>

<div class="container">
	<jsp:include page="view/viewHeader.jsp" flush="true"/>
	
	<div class="product_div">
		
		<div class="product_header">
			선물 상세 내역
			<input type="hidden" id="product_seq" value="<%=product.getProduct_seq()%>">
		</div>
		<div class="product_content">
		
			<div class="product_wrapper">
				<div class="product_text">선물 이미지</div>
				<div class="product_input_div">
					<%if(product.getImage_list() == null || product.getImage_list().size() == 0){%>
						<img src="/image/no_photo.jpg" style="width:385px; height:350px; border: 1px solid #aaa;"/>
					<%}else{
						for(int i = 0; i < product.getImage_list().size(); i++){ %>
							<img src="<%=imagePath +  product.getImage_list().get(i).getImage_path()%>" style="width:385px; height:350px; border: 1px solid #aaa;"/>
						<%}
					}%>
				</div>
				<div class="clear"></div>
			</div>
			
			<!-- certifyAccount.action을 통해서 넘어오는 데이터 -->
			<div class="product_wrapper">
				<div class="product_text" style="line-height: 200%">선물 설명</div>
				<div class="product_input_div" style="line-height: 200%">
					<div class="top_comment">저는 <font color="#789">서울</font>사는 <font color="#789"><%=product.getSeller() %></font> 입니다.</div>
					<div class="middle_comment">저는 <font color="#789"><%=product.getP_name() %></font>을 선물로 드리고 싶어요.</div>
					<div class="bottom_comment">이  <font color="#789"><%=product.getP_name() %></font>는요, <%=product.getP_detail()%>.</div>
				</div>
				<div class="clear"></div>
			</div>
			
			<%if(product.getRegist_type().equals("포인트")){ %>
				<div class="product_wrapper">
					<div class="product_text">포인트</div>
					<div class="product_input_div">
						<%=product.getP_point() %>		
					</div>
					<div class="clear"></div>
				</div>
				
				<div class="product_wrapper">
					<input class="product_button" type="button" value="이 선물을 받으시겠습니까?" onclick="receiveProduct(event)"/>
					<div class="clear"></div>
				</div>
			<%}
			else if(product.getRegist_type().equals("선물")){
				if(product.getReply_list().size() > 0){
					for(int i = 0; i < product.getReply_list().size(); i++){
						if(me == true){%>
							<div class="product_reply product_wrapper" style="cursor: pointer;" 
							onclick="giveProduct(event, <%=product.getReply_list().get(i).getReply_seq()%>,
							<%=product.getReply_list().get(i).getMember_seq()%>,
							'<%=product.getReply_list().get(i).getMember_name()%>')">
						<%}else{ %>
							<div class="product_reply product_wrapper">
						<%} %>
							<div class="product_text">
								<%=product.getReply_list().get(i).getMember_name()%>
							</div>
							<div class="product_input_div">
								<%=product.getReply_list().get(i).getComment()%>		
							</div>
							<div class="clear"></div>
						</div>
						
					<%}
				}
				
				if(me == false){%>
					<div class="product_write_reply product_wrapper">
						<div class="product_text">
							사연 작성
						</div>
						<div class="product_input_div">
							<div class="product_input_top">
								<input type="text" id="reply_comment" class="product_input">
							</div>
							<div class="product_input_middle">
								<input type="button" id="reply_button" class="product_button" onclick="postReply()" value="사연 올리기">
							</div>		
						</div>
						<div class="clear"></div>
					</div>
				<%}
			}%>
		</div>
	</div>
</div>



</body>
</html>